Skip to content

refactor(NODE-7445): replace whatwg-url with native URL/URLSearchParams#115

Open
bjnewman wants to merge 1 commit intomongodb-js:mainfrom
bjnewman:remove-whatwg-url
Open

refactor(NODE-7445): replace whatwg-url with native URL/URLSearchParams#115
bjnewman wants to merge 1 commit intomongodb-js:mainfrom
bjnewman:remove-whatwg-url

Conversation

@bjnewman
Copy link
Copy Markdown

Summary

Removes whatwg-url and @types/whatwg-url as runtime dependencies. Since v7.0.0 requires Node >= 20.19.0, the native URL implementation (Ada-backed since Node 18) is already WHATWG-compliant, making the polyfill unnecessary.

There's no open issue for this — I expect this is something you're already aware of and just haven't gotten around to. Happy to adjust anything.

What changed

  • Removed whatwg-url and @types/whatwg-url from dependencies
  • Removed the import { URL, URLSearchParams } from 'whatwg-url' import
  • Replaced the URLWithoutHost abstract class with a re-typed URLBase constant using Omit<> to handle the TS2611 property-vs-accessor conflict with native URL's type declarations

All 61 existing tests pass without modification. Also verified with the mongodb driver in a test project — parsing, redaction, cloning, and case-insensitive params all work as expected.

Since v7.0 requires Node.js >= 20.19.0, the native URL class (backed
by Ada) provides identical WHATWG-compliant parsing. This removes the
whatwg-url, tr46, webidl-conversions, and @types/whatwg-url dependencies.
@bjnewman bjnewman requested a review from a team as a code owner February 13, 2026 05:15
@alexbevi
Copy link
Copy Markdown

alexbevi commented Feb 13, 2026

@bjnewman this is awesome as it would likely address the Error: Dynamic require of "punycode/" is not supported error you can get in Cloudflare Workers (check here for more details)

@PavelSafronov PavelSafronov changed the title refactor: replace whatwg-url with native URL/URLSearchParams refactor(NODE-7391): replace whatwg-url with native URL/URLSearchParams Feb 13, 2026
@PavelSafronov
Copy link
Copy Markdown
Contributor

@bjnewman thanks so much for your contribution! The team is going to prioritize this PR and NODE-7391 at our next triage session.

@dariakp dariakp changed the title refactor(NODE-7391): replace whatwg-url with native URL/URLSearchParams refactor(NODE-7445): replace whatwg-url with native URL/URLSearchParams Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants